import Vue from 'vue'
import promptBox from './promptBox.vue'
let prompBoxConstructor = Vue.extend(promptBox);
let PromptBoxFunc = function (content) {
    return new Promise((res, rej) => {
        let prompBoxExample = new prompBoxConstructor({
            el: document.createElement('div')
            //data:content 不能直接覆盖 data 会报 bug 原data 有 对于 vue的引用 ，覆盖后就没有了
        });
        //console.log(prompBoxExample);
        //return;
        prompBoxExample.conetnt = content;
        document.body.appendChild(prompBoxExample.$el);
        prompBoxExample.ok = function () {
            res();
            prompBoxExample.conetnt.visible = false;
        }
        // console.log(prompBoxExample);
        prompBoxExample.no = function () {
            rej();
            prompBoxExample.conetnt.visible = false;
        }
    });
}
PromptBoxFunc.show = options => {
    options.visible = true;
    return PromptBoxFunc(options);
}

export default PromptBoxFunc;